package com.fiidee.blog.util;

import com.fiidee.blog.common.SystemSetting;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by 瑱彬 on 2015/5/27.
 */
public class CookieAndSessionUtil {
    public static void addCookie(String key,String value,HttpServletResponse response){
        Cookie cookie = new Cookie(key,value);
        cookie.setPath("/");
        cookie.setMaxAge(SystemSetting.COOKIEMAXAGE);
        response.addCookie(cookie);
    }

    public static void removeCookie(String key,HttpServletResponse response){
        Cookie cookie = new Cookie(key,null);
        cookie.setPath("/");
        cookie.setMaxAge(0);
        response.addCookie(cookie);
    }

}
